<!-- 扫码弹窗 -->
<template>
	<view>
		<u-popup :show="show" @close="close" @open="open" mode="center" :closeOnClickOverlay="false" :round="5">
			<view class="title">扫描内容</view>
			<scroll-view class="scrollView" scroll-y>
				<view class="content">
					<view class="action">
						<view class="list1">单据编号</view>
						<view class="list2">{{ model.billNo }}</view>
					</view>
					<view class="action">
						<view class="list1">单据分类</view>
						<view class="list2">{{ billType(model.billType) }}</view>
					</view>
					<view class="action">
						<view class="list1">申请人/报销人</view>
						<view class="list2">{{  filterMultiDictText(dictOptions['reimburser'], model.reimburser + '') }}</view>
					</view>
					<view class="action">
						<view class="list1">本次付款/支付金额(元)</view>
						<view class="list2">{{ model.paymentAmount }}</view>
					</view>
				</view>
			</scroll-view>
			<view class="task_bottom">
				<u-button type="primary" :plain="true" text="取消" @click="close"></u-button>
				<view style="width: 200rpx;"></view>
				<u-button type="primary" text="确认交单" @click="handleConfirm"></u-button>
			</view>
		</u-popup>
	</view>
</template>
<script>
	import { filterMultiDictText, initDictOptions } from '@/utils/JDictSelectUtil.js'
	import http from '@/utils/request/index.js'
	export default {
		name: 'sacanCodePopup',
      data() {
        return {
          show: false,
					model: {},
					dictOptions: {},
					filterMultiDictText
        }
      },
      methods: {
				edit(record) {
					if (!this.dictOptions || !this.dictOptions.reimburser) {
						this.initDictConfig()
					}
					this.model = Object.assign({}, record);
				},
        open() {
        },
        close() {
          this.show = false
					this.$nextTick(() => {
						this.model = {}
					})
        },
				// 点击确认
				handleConfirm () {
					var _this = this
					var params = Object.assign({}, this.model)
					uni.showModal({
						title: '确认交单',
						content: '是否确认交单？',
						success: (res) => {
							if (res.confirm) {
								http.post('/api/erp/finance/record/erpFinancePaymentAgainstDocumentsRecord/submitDocument', params).then(res => {
									if (res.success) {
										uni.showToast({
											title: res.message,
											icon: 'none'
										})
									} else {
										uni.showToast({
											title: res.message,
											icon: 'none'
										})
									}
								}).finally(() => {
									_this.close()
								})
							} else if (res.cancel) {
								// 用户点击取消
							}
						}
					})
					
				},
				billType (text) {
					var name = ''
					if (text == '1') {
						name = '费用报销申请'
					} else if (text == '2') {
						name = '差旅报销申请'
					} else if (text == '3') {
						name = '付款申请'
					} else if (text == '4') {
						name = '保证金申请'
					} else if (text == '5') {
						name = '借款申请'
					}
					return name
				},
				initDictConfig() {
					initDictOptions('erp_employee_file,name,id').then((res) => {
						if (res.success) {
							this.$set(this.dictOptions, 'reimburser', res.result)
						}
					})
				},
      }
	}
</script>
<style lang="scss" scoped>
@import "@/pages/synergy/common/action.scss";
.title{ 
	font-size: 14px;
	// font-family: PingFangSC-Medium, PingFang SC;
	font-weight: 600;
	color: #171717;
	text-align: center;
	padding: 20rpx;
	border-bottom: 1px solid #ccc;
}
.scrollView{
	width: 80vw;
	max-height: 80vh;
}
.content{
	padding:0 20rpx;
}
.task_bottom{
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 20rpx;
}
</style>